package cn.com.dhc.chesishan;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HelloForm1 extends HttpServlet {

	//使用url的get方法
	private static final long serialVersionUID = 1861045281638854723L;

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		//设置相应内容类型
		response.setContentType("text/html");
		response.setCharacterEncoding("UTF-8"); //注意编码类型的修改,否则出现乱码
		

		
		PrintWriter out=response.getWriter();
		String title="使用GET方法读取表单数据";
		String docType="<!doctype html public \"-//w3c//dtd html 4.0"+"transitional//en\">\n";
		out.println(docType+"<head><meta charset=\"UTF-8\"/><title>"+title+"</head></title>\n"+  ////注意编码类型的修改,否则出现乱码
		"<body bgcolor=\"#f0f0f0\">\n"+
		"<h1 align=\"center\">"+title+"</h1>\n"+
		"<ul>\n"+
		"<li><b>名字</b>:"
		+request.getParameter("first_name")+"\n"
		+"<li><b>姓氏</b>:"
		+request.getParameter("last_name")+"\n"+
		"</ul>\n"+
		"</body></html>");
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
	}

}
